# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Dict, List, Union
from pydantic import BaseModel, Field
from fastapi import Query


class QueryPolicyIn(BaseModel):
    """ 协议查询参数"""
    type: str = Query(..., pattern=r"^(service|private|payment)$", description="协议类型")

    class Config:
        json_schema_extra = {
            "example": {
                "type": "service"
            }
        }


class SendSmsIn(BaseModel):
    """ 发送短信参数"""
    scene: int = Field(..., description="发送场景")
    mobile: str = Field(..., description="手机号码")

    class Config:
        json_schema_extra = {
            "example": {
                "scene": 101,
                "mobile": "13800138000"
            }
        }


class SendEmailIn(BaseModel):
    """ 发送邮件参数 """
    scene: int = Field(..., description="发送场景")
    email: str = Field(..., description="邮件号码")

    class Config:
        json_schema_extra = {
            "example": {
                "scene": 120,
                "mobile": "wait@163.com"
            }
        }


"""--------------- Separator ---------------"""


class AiModelsVo(BaseModel):
    """ AI模型Vo """
    class Llm(BaseModel):
        model: str = Field(description="模型")
        alias: str = Field(description="别名")
        price: int = Field(description="售价")
        modal: bool = Field(description="多模态")
        think: bool = Field(description="深度思考")
        func: bool = Field(description="FunCall")
        max_tokens: int = Field(description="最大输出Tokens")

    mark: str = Field(description="通道标识")
    name: str = Field(description="通道名称")
    logo: str = Field(description="通道图标")
    config: List[dict] = Field(description="模型配置")
    models: List[Llm] = Field(description="模型列表")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "name": "OpenAI",
                "logo": "https://www.xx.cn/models/gpt3.5.png",
                "models": [
                    {
                        "model": "gpt-3.5-turbo",
                        "alias": "gpt35",
                        "price": "0.001",
                        "modal": True,
                        "think": True,
                        "func": True,
                        "max_tokens": 8810
                    }
                ]
            }
        }


class AiBroadcast(BaseModel):
    """ 语音播报Vo """
    key: str = Field(description="通道标识")
    name: str = Field(description="通道名称")
    speed: float = Field(description="语音速度")
    speed_range: List[float] = Field(description="速度范围")
    pronounces: Dict[str, str] = Field(description="发音人列表")

    class Config:
        json_schema_extra = {
            "example": {
                "key": "xunfei",
                "name": "讯飞星火",
                "speed": 31.0,
                "speed_range": [
                    10.0,
                    100.0,
                    1.0
                ],
                "pronounces": {
                    "x4_lingxiaoxuan_oral": "聆小璇",
                    "x4_lingfeizhe_oral": "聆飞哲",
                    "x4_lingyuzhao_oral": "聆玉昭"
                }
            }
        }


class ConfigVo(BaseModel):
    """ 全局配置Vo """
    oss_domain: str = Field(description="存储域名")
    login: Dict[str, object] = Field(description="登录配置")
    website: Dict[str, str] = Field(description="网站配置")
    pc: Dict[str, str] = Field(description="PC配置")
    dialog: Dict[str, str] = Field(description="对话配置")
    switch: Dict[str, bool] = Field(description="开关配置")
    bulletin: Dict[str, Union[str, bool]] = Field(description="公告配置")

    class Config:
        json_schema_extra = {
            "example": {
                "oss_domain": "https://www.xx.cn",
                "login": {
                    "is_agreement": 1,
                    "defaults": "account",
                    "register": ["mobile", "email"],
                    "means": ["account", "mobile"],
                    "oauth": ["wx"]
                },
                "website": {
                    "icp": "",
                    "pcp": "",
                    "domain": "",
                    "analyse": "",
                    "copyright": "",
                    "customer_link": ""
                },
                "pc": {
                    "logo": "https://www.xxx.com/logo_pc.png",
                    "favicon": "https://www.xxx.com/favicon.png",
                    "title": "",
                    "keywords": "",
                    "description": ""
                },
                "dialog": {
                    "default_robot": "a513st5gf8fbb9vk",
                    "currency_unit": "积分",
                    "win_watermark": "水印"
                },
                "switch": {
                    "recharge": True,
                    "broadcast": True
                },
                "bulletin": {
                    "is_open": False,
                    "title": "",
                    "content": ""
                }
            }
        }


class PolicyVo(BaseModel):
    """ 政策协议Vo """
    content: str = Field(description="协议内容")

    class Config:
        json_schema_extra = {
            "example": {
                "content": ""
            }
        }


class MonitorVo(BaseModel):
    """ 消息监听Vo """
    unread: int = Field(default=0, description="未读消息数")


class UploadResultVo(BaseModel):
    """ 上传结果Vo """
    id: Union[int, str] = Field(description="主键")
    name: str = Field(description="文件名称")
    ext: str = Field(description="文件扩展")
    size: int = Field(description="文件大小")
    path: str = Field(description="文件路径")
    url: str = Field(description="访问路径")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 6,
                "name": "bot.png",
                "ext": "png",
                "size": 666857,
                "path": "storage/492bd.png",
                "url": "https://www.xxx.com/storage/492bd.png"
            }
        }
